<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<button>按钮</button>
<script>
    /*window.onload = function () {
        var btn = document.querySelector('button');
        btn.addEventListener('click',function () {
            alert('666666');
        })
    };
    window.onload = function () {
        var btn = document.querySelector('button');
        btn.addEventListener('click',function () {
            alert('888888');
        })
    }*/
    //使用传统方法注册的只能执行最后一个
    window.addEventListener('load',function () {
        var btn = document.querySelector('button');
        btn.addEventListener('click',function () {
            alert('666666');
        })
    });
    window.addEventListener('load',function () {
        var btn = document.querySelector('button');
        btn.addEventListener('click',function () {
            alert('888888');
        })
    });
    document.addEventListener('DOMContentLoaded',function () {
        alert('99');
    })
</script>
</body>
</html>